package PTA.ch06.ex03;

import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class  Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<String> set = new TreeSet<>();
while(true){
    String line = sc.next();
    if(line.equals("!!!!!")){
        break;
    }else{
        set.add(line);
    }
}
        System.out.println(set.size());
        int count=0;
        if(set.size()<10){
            for(String s:set){
                System.out.println(s);
            }
        }else{
            for(String s:set){
                if(count++>9){
                    break;

                }
                System.out.println(s);
            }
        }
        sc.close();
    }
}